#include "home_page.h"
#include "lv_app_conf.h"
#include "../com/vplayer/vplayer.h"

void create_home_screen(lv_obj_t * parent) {
    // 创建标题
    //lv_obj_t *title = lv_label_create(parent);
    //lv_label_set_text(title, "Video Player Demo");
    //lv_obj_align(title, LV_ALIGN_TOP_MID, 0, 20);
    
    // 创建视频播放器组件
    vplayer_t *vplayer = vplayer_create(parent);
    
    // 设置视频源
    lv_res_t res = vplayer_set_src(vplayer, VIDEO_TEST_FILE_PATH);
    
    // 如果视频加载失败，显示错误信息
    if (res != LV_RES_OK) {
        lv_obj_t *error_label = lv_label_create(parent);
        lv_label_set_text(error_label, "Error: Cannot load video file");
        lv_obj_align(error_label, LV_ALIGN_CENTER, 0, 0);
        return;
    }
    
    // 开始播放视频
    vplayer_play(vplayer);
}